<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0"
                xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                xmlns:x="http://schemas.microsoft.com/xps/2005/06/resourcedictionary-key">

  <xsl:output method="xml" version="1.0" omit-xml-declaration="yes" indent="yes" encoding="utf-8"/>

  <xsl:include href="include/Slices.xslt"/>

  <xsl:template match="/">
    
    <FlowDocument  PageWidth="21cm"
      PagePadding="60,40,40,40"
      PageHeight="29.7cm"
      ColumnWidth="21 cm">

      <xsl:call-template name="StyleSettings"/>

      <xsl:call-template name="Header">
        <xsl:with-param name="type" select="'Task Report'"/>
        <xsl:with-param name="context" select="/ProjectHourBankDataSet"/>
      </xsl:call-template>

      <xsl:call-template name="TaskWithoutUnitAlert"/>



      <Table Style="{{StaticResource NoBorderTable}}" Margin="0,0,0,0">

        <xsl:call-template name="ColumnDefinition"/>

        <TableRowGroup>

          <!-- QUEBRA EM ITEM DE BACKLOG -->
          <xsl:for-each select="/ProjectHourBankDataSet/Project/BacklogItem">
            <xsl:sort select="BacklogItemNumber" data-type="number"/>

            <xsl:sort select="Status" data-type="number" order="descending"/>
            <xsl:sort select="BusinessValue" data-type="number" order="descending"/>
            <xsl:sort select="BacklogItemNumber" data-type="number" order="descending"/>

            <xsl:variable name="backlogItemNumber" select="BacklogItemNumber"></xsl:variable>
            <xsl:variable name="backlogItemUId" select="BacklogItemUId"></xsl:variable>

            <!-- HEADER DO ITEM DE BACKLOG -->
            <xsl:call-template name="BacklogItemHeader">
              <xsl:with-param name="backlogItemUId" select="$backlogItemUId"/>
              

            </xsl:call-template>
            <xsl:call-template name="TaskHeader"/>

            <!-- TAREFAS DO ITEM DO BACKLOG -->
            <xsl:call-template name="BacklogItemTasks">
              
              <xsl:with-param name="backlogItemUId" select="$backlogItemUId"/>
              
            </xsl:call-template>

            <!-- SOMATÓRIA DO ITEM DE BACKLOG -->
            <xsl:call-template name="BacklogItemSum">
              
              <xsl:with-param name="backlogItemUId" select="$backlogItemUId"/>
              <xsl:with-param name="backlogItemNumber" select="$backlogItemNumber"/>
              
            </xsl:call-template>

          </xsl:for-each>

        </TableRowGroup>
      </Table>
   
    </FlowDocument>

  </xsl:template>




</xsl:stylesheet>